3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next |
To write a drawing engine, you need to implement several private methods for managing draw contexts.
Pointers to your drawing engine's private draw context methods are returned to QuickDraw 3D RAVE by your TQAEngineGetMethod method. See page [link] for details.
A drawing engine must define a method to create its own private data and initialize a new draw context.
typedef TQAError (*TQADrawPrivateNew) (
TQADrawContext *newDrawContext,
const TQADevice *device,
const TQARect *rect,
const TQAClip *clip,
unsigned long flags);
Your TQADrawPrivateNew function is called whenever an application calls QADrawContextNew to create a new draw context associated with your drawing engine. Your function should perform any initialization required for the new draw context. In particular, it should return a pointer to the draw context's private data in the drawPrivate field of the draw context structure pointed to by the newDrawContext parameter. In addition, your TQADrawPrivateNew function should set any other fields of that draw context structure to point to public draw context methods defined by the drawing engine.
Because it is the responsibility of your TQADrawPrivateNew function to initialize the fields of a draw context structure, you can load different methods depending on the features of the device or draw context specified by the device and flags parameters. For instance, you might load one line drawing function for a device that displays 16 bits per pixel and a different line drawing function for a device that displays 32 bits per pixel. This technique allows you to avoid testing the display depth each time you draw a line.
See Listing 11 for a sample TQADrawPrivateNew function.
A drawing engine must define a method to delete its private data.
typedef void (*TQADrawPrivateDelete) (TQADrawPrivate *drawPrivate);
A drawing engine must define a method to indicate whether the engine can draw to a particular device.
typedef TQAError (*TQAEngineCheckDevice) (const TQADevice *device);
A drawing engine must define a method to return information about its capabilities.
typedef TQAError (*TQAEngineGestalt) (
TQAGestaltSelector selector,
void *response);
Previous | QD3D Book | Overview | Chapter Contents | Next |